import request from "@/utils/request";

class AuthAPI {

	//获取环境配置
	static getConfigInfo(AuthorizeCode: string) {
		return request<any>({
		  url: `/config/get_config`,
		  method: "get",
		  headers: {
			token: AuthorizeCode,
		  },
		});
	  }
	//  系统点击保存
	static updateSet(AuthorizeCode: string, data: any) {
		// console.log('data2222222222', data);
		// 创建 FormData 对象
		// const formData = new FormData();
		
		// 将 data 对象中的键值对添加到 FormData 对象中
		// for (const key in data) {
		//   if (data.hasOwnProperty(key)) {
		// 	if (typeof data[key] === 'object') {
		// 	  for (const subKey in data[key]) {
		// 		if (data[key].hasOwnProperty(subKey)) {
		// 		  formData.append(`${key}[${subKey}]`, data[key][subKey]);
		// 		}
		// 	  }
		// 	} else {
		// 	  formData.append(key, data[key]);
		// 	}
		//   }
		// }
		
		// 发送请求
		return request<any>({
		  url: "/config/set_config",
		  method: "post",
		  data: data,
		  headers: {
			token: AuthorizeCode,
		  },
		});
	  }
	  	//获取大模型配置
	static getLargeModalInfo(AuthorizeCode: string) {

		return request<any>({
		url: `/config/get_big_model_info`,
		method: "get",
		//   params:formobj,
		headers: {
			token: AuthorizeCode,
		},
		});
	  }
	  //大模型点击保存
	  static updateSetLargeModal(AuthorizeCode: string, data: any) {
		console.log('data===',data);
		
		// 发送请求
		return request<any>({
		  url: "/config/set_big_model_info",
		  method: "post",
		  data: data,
		  headers: {
			token: AuthorizeCode,
		  },
		});
	  };

	//获取知识库配置
	static getKbModalInfo(AuthorizeCode: string) {
		return request<any>({
		  url: `/config/get_kb_model_info`,
		  method: "get",
		//   params:formobj,
		  headers: {
			token: AuthorizeCode,
		  },
		});
	  };

	  //知识库点击保存
	  static updateKnowLedgeCard(AuthorizeCode: string, data: any) {
		console.log('data===',data);
		// 发送请求
		return request<any>({
		  url: "/config/set_kb_model_info",
		  method: "post",
		  data: data,
		  headers: {
			token: AuthorizeCode,
		  },
		});
	  };

	//获取提示词配置
	static getPromptInfo(AuthorizeCode: string) {
		return request<any>({
		  url: `/config/get_prompt_info`,
		  method: "get",
		//   params:formobj,
		  headers: {
			token: AuthorizeCode,
		  },
		});
	  };
	  //提示词点击保存
	  static updatePromptInfo(AuthorizeCode: string, data: any) {
		console.log('data===',data);
		// 发送请求
		return request<any>({
		  url: "/config/set_prompt_info",
		  method: "post",
		  data: data,
		  headers: {
			token: AuthorizeCode,
		  },
		});
	  };
}
export default AuthAPI;
